<basics2:ChildWindow xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:basics="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:basics2="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:common="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:Rage="clr-namespace:Rage;assembly=Rage.Base.WPF"
    xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.WPFToolkit"
    mc:Ignorable="d"
    x:Class="Rage.UI.EditItemFilter"
    Title="Edit Item Filters..."
    Width="641" Height="440" xmlns:my="clr-namespace:Rage.UI">
    <basics2:ChildWindow.Resources>
        <my:PercentConverter x:Key="PercentConverter1" />
    </basics2:ChildWindow.Resources>
    <basics2:ChildWindow.DataContext>
        <Rage:ItemFilterRegex/>
    </basics2:ChildWindow.DataContext>

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <common:HierarchicalDataTemplate x:Key="FilterTemplate" ItemsSource="{Binding RegexList}">
                <TextBlock Text="{Binding Name}" />
            </common:HierarchicalDataTemplate>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="50*" />
            <ColumnDefinition Width="85"/>
            <ColumnDefinition Width="50*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid VerticalAlignment="Stretch" Grid.Row="0" Margin="2" Grid.Column="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" Margin="2" x:Name="NewFilterButton" Content="New Filter" Click="NewFilter" />
            <Button Grid.Column="1" Margin="2" x:Name="SubfilterButton" Content="New Subfilter" Click="NewSubfilter"/>
            <Button Grid.Column="3" Margin="2" x:Name="MoveUpButton" Content="+" Grid.ColumnSpan="1" Width="24" Click="MoveUpFilter"/>
            <Button Grid.Column="4" Margin="2" x:Name="MoveDownButton" Content="-" Grid.ColumnSpan="1" Width="24" Click="MoveDownFilter"/>
            <Button Grid.Column="5" Margin="2" x:Name="DeleteButton" Content="X" Grid.ColumnSpan="1" Width="24" HorizontalAlignment="Left" Click="DeleteFilter"/>
        </Grid>

        <basics:TreeView x:Name="FilterTree" Margin="4" ItemTemplate="{StaticResource FilterTemplate}" Grid.Row="1" SelectedItemChanged="SelectedFilterChanged" Grid.RowSpan="11" />
        
        <TextBlock HorizontalAlignment="Right" Grid.Row="0" Text="Name:" VerticalAlignment="Center" Margin="4,2,4,0" Grid.Column="1" />
        <TextBox HorizontalAlignment="Stretch" Margin="2,2,4,2" Grid.Column="2" Grid.Row="0" TextWrapping="Wrap" Text="{Binding Name, Mode=TwoWay}"/>
        <TextBlock HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Row="2" Text="Pattern:" Margin="4,2,4,0" Grid.Column="1" />
        <TextBox HorizontalAlignment="Stretch" Margin="2,2,4,2" Grid.Column="2" Grid.Row="2" TextWrapping="Wrap" Text="{Binding Pattern, Mode=TwoWay}"/>
        <TextBlock HorizontalAlignment="Right" Grid.Row="3" Text="Item Level:" VerticalAlignment="Center" Margin="4,2,4,0" Grid.Column="1" />
        <StackPanel Grid.Column="2" Grid.Row="3" Orientation="Horizontal">
            <TextBox Margin="2" Width="75" Grid.Column="2" Grid.Row="3" Text="{Binding MinItemLevel, Mode=TwoWay}" FlowDirection="RightToLeft" />
            <TextBlock Margin="2" VerticalAlignment="Center" Grid.Column="2" Text="-"/>
            <TextBox Margin="2" Width="75" Grid.Column="2" Grid.Row="4" Text="{Binding MaxItemLevel, Mode=TwoWay}" FlowDirection="RightToLeft" />
        </StackPanel>
        <TextBlock HorizontalAlignment="Right" Grid.Row="4" Text="Drop Rate:" VerticalAlignment="Center" Margin="4,2,4,0" Grid.Column="1" />
        <StackPanel Grid.Column="2" Grid.Row="4" Orientation="Horizontal">
            <inputToolkit:NumericUpDown Margin="2" Width="75" Value="{Binding Mode=TwoWay, Path=MinDropRatePerc, Converter={StaticResource PercentConverter1}}" DecimalPlaces="2" />
            <TextBlock Margin="2" VerticalAlignment="Center" Text="-"/>
            <inputToolkit:NumericUpDown Margin="2" Width="75" Value="{Binding Mode=TwoWay, Path=MaxDropRatePerc, Converter={StaticResource PercentConverter1}}" DecimalPlaces="2" />
        </StackPanel>
        <TextBlock HorizontalAlignment="Right" Grid.Row="5" Text="Item Quality:" VerticalAlignment="Center" Margin="4,2,4,0" Grid.Column="1" />
        <StackPanel Grid.Column="2" Grid.Row="5" Orientation="Horizontal">
            <ComboBox Margin="2" Width="130" SelectedIndex="{Binding MinItemQualityIndex, Mode=TwoWay}">
                <ComboBoxItem Content="Temp"/>
                <ComboBoxItem Content="Poor"/>
                <ComboBoxItem Content="Common"/>
                <ComboBoxItem Content="Uncommon"/>
                <ComboBoxItem Content="Rare"/>
                <ComboBoxItem Content="Epic"/>
                <ComboBoxItem Content="Legendary"/>
                <ComboBoxItem Content="Artifact"/>
                <ComboBoxItem Content="Heirloom"/>
            </ComboBox>
            <ComboBox Margin="2" Width="130" SelectedIndex="{Binding MaxItemQualityIndex, Mode=TwoWay}">
                <ComboBoxItem Content="Temp"/>
                <ComboBoxItem Content="Poor"/>
                <ComboBoxItem Content="Common"/>
                <ComboBoxItem Content="Uncommon"/>
                <ComboBoxItem Content="Rare"/>
                <ComboBoxItem Content="Epic"/>
                <ComboBoxItem Content="Legendary"/>
                <ComboBoxItem Content="Artifact"/>
                <ComboBoxItem Content="Heirloom"/>
            </ComboBox>
        </StackPanel>
        
        <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="4,2,4,0" Grid.Row="7" Text="Item Bind Status:" Grid.Column="1" TextWrapping="Wrap" TextAlignment="Right" />
        <CheckBox HorizontalAlignment="Left" Content="Pickup" Grid.Row="7" Margin="2,2,0,0" Grid.Column="2" IsChecked="{Binding BoP, Mode=TwoWay}" Height="17" VerticalAlignment="Top"/>
        <CheckBox HorizontalAlignment="Left" Content="Equip" Grid.Row="7" Margin="63,3,0,0" Grid.Column="2" IsChecked="{Binding BoE, Mode=TwoWay}" Height="17" VerticalAlignment="Top"/>
        <CheckBox HorizontalAlignment="Left" Content="Use" Grid.Row="7" Margin="125,3,0,0" Grid.Column="2" IsChecked="{Binding BoU, Mode=TwoWay}" Height="17" VerticalAlignment="Top"/>
        <CheckBox HorizontalAlignment="Left" Content="N/A" Grid.Row="7" Margin="2,22,0,0" Grid.Column="2" IsChecked="{Binding BoN, Mode=TwoWay}" Height="17" VerticalAlignment="Top"/>
        <CheckBox HorizontalAlignment="Left" Content="Account" Grid.Row="7" Margin="63,22,0,0" Grid.Column="2" IsChecked="{Binding BoA, Mode=TwoWay}" Height="17" VerticalAlignment="Top"/>
        
        <CheckBox HorizontalAlignment="Left" Content="Additive Filter" Grid.Row="8" Margin="2,2,2,2" Grid.Column="2" IsChecked="{Binding AdditiveFilter, Mode=TwoWay}"/>
        <CheckBox HorizontalAlignment="Left" Content="Applies to Items" Grid.Row="9" Margin="2,2,2,2" Grid.Column="2" IsChecked="{Binding AppliesToItems, Mode=TwoWay}"/>
        <CheckBox HorizontalAlignment="Left" Content="Applies to Gems" Grid.Row="10" Margin="2,2,2,2" Grid.Column="2" IsChecked="{Binding AppliesToGems, Mode=TwoWay}"/>

        <Button x:Name="OKButton" Content="Done" Click="OKButton_Click" Grid.Row="11" Margin="0,8,4,4" Grid.Column="2" HorizontalAlignment="Right" Width="75" d:LayoutOverrides="GridBox" />
    </Grid>
</basics2:ChildWindow>